# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//bazel:pl_build_system.bzl", "pl_go_test")

go_library(
    name = "k8s",
    srcs = [
        "apply.go",
        "auth.go",
        "delete.go",
        "dns_addr.go",
        "kubectl.go",
        "logs.go",
        "secrets.go",
        "selector.go",
    ],
    importpath = "px.dev/pixie/src/utils/shared/k8s",
    visibility = ["//src:__subpackages__"],
    deps = [
        "@com_github_sirupsen_logrus//:logrus",
        "@com_github_spf13_pflag//:pflag",
        "@io_k8s_api//core/v1:core",
        "@io_k8s_apimachinery//pkg/api/errors",
        "@io_k8s_apimachinery//pkg/api/meta",
        "@io_k8s_apimachinery//pkg/apis/meta/v1:meta",
        "@io_k8s_apimachinery//pkg/apis/meta/v1/unstructured",
        "@io_k8s_apimachinery//pkg/runtime",
        "@io_k8s_apimachinery//pkg/runtime/schema",
        "@io_k8s_apimachinery//pkg/runtime/serializer/json",
        "@io_k8s_apimachinery//pkg/util/sets",
        "@io_k8s_apimachinery//pkg/util/validation",
        "@io_k8s_apimachinery//pkg/util/yaml",
        "@io_k8s_cli_runtime//pkg/genericclioptions",
        "@io_k8s_cli_runtime//pkg/printers",
        "@io_k8s_cli_runtime//pkg/resource",
        "@io_k8s_client_go//discovery",
        "@io_k8s_client_go//discovery/cached/memory",
        "@io_k8s_client_go//dynamic",
        "@io_k8s_client_go//kubernetes",
        "@io_k8s_client_go//plugin/pkg/client/auth",
        "@io_k8s_client_go//rest",
        "@io_k8s_client_go//restmapper",
        "@io_k8s_client_go//tools/clientcmd",
        "@io_k8s_client_go//tools/clientcmd/api",
        "@io_k8s_klog_v2//:klog",
        "@io_k8s_kubectl//pkg/cmd/util",
        "@io_k8s_kubectl//pkg/cmd/wait",
    ],
)

pl_go_test(
    name = "k8s_test",
    srcs = [
        "apply_test.go",
        "dns_addr_test.go",
    ],
    deps = [
        ":k8s",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@io_k8s_api//core/v1:core",
        "@io_k8s_apimachinery//pkg/apis/meta/v1:meta",
    ],
)
